package 相向双指针

func minimumLength(s string) int {
	left := 0
	right := len(s) - 1
	b := []byte(s)
	for left < right && b[left] == b[right] {
		c := b[left]
		for left <= right && b[left] == c {
			left++
		}
		// 跳过结尾所有连续的 c
		for left <= right && b[right] == c {
			right--
		}
	}
	return right - left + 1
}
